package system;

import java.util.ArrayList;

public class ActionPoint {

double x;
double y;
ArrayList<Tile> tiles = new ArrayList<Tile>();
HouseType type;
Player p; //the player controllign this point

public ActionPoint(double x, double y){
	this.x =x;
	this.y = y;
	type = HouseType.NONE;
}



/**
 * upgrades the current building on this point, if it stil has none it makes it a house assuming the owner is
 * already assigned before. trying to upgrade a city does nothing
 * 
 * @pre
 * 		assumes the player controlling this point is already assigned
 * 
 */
public void upgrade(){
	if (type!= HouseType.CITY){
		type = HouseType.values()[type.ordinal()+1];
	}
}

public void assign(Player p){
	type = HouseType.HOUSE;
	this.p = p;
}

public Player getOwner(){
	return p;
}

public HouseType getType(){
	return type;
}

public void addTile(Tile t){
	tiles.add(t);
}

public ArrayList<Tile> getTiles() {
	return tiles;
}

@Override
public boolean equals(Object p){
	if (! (p instanceof ActionPoint))
	return false;
	else
	return x==((ActionPoint) p).getX() && y == ((ActionPoint) p).getY();
}


public double getX() {
	return x;
}


public double getY() {
	return y;
}

@Override
public String toString(){
	return "(" + x + "," + y + ")";
}

public static void main(String args[]){
	System.out.println((new ActionPoint(1,2)).equals(new ActionPoint(1,2)));
	System.out.println(! new ActionPoint(2,2).equals(new ActionPoint(1, 2)));
	System.out.println(! new ActionPoint(1,1).equals(new ActionPoint(1, 2)));

}
	
}
